	*------------------------------------------------------------------------------------------------------------%	
	* Figure 9: Cross-wage elasticities compared to estimates in the literature
	*------------------------------------------------------------------------------------------------------------%	
	use "$figures_tables/cwe_estimates_pooled_for_plotting.dta", clear
	rename stderr se
	rename min95 lb 
	rename max95 ub
	*replace exp_group="$15" if exp_group=="m15"
	gen tempid=_n
	gsort - tempid
	replace type = type + "_" + exp_group
	keep estimate se lb ub type
	tempfile dw_estimates
	save `dw_estimates'
	
	import excel using "$data/spillover_estimates_literature/spillover_estimates_literature.xlsx", clear first 
	gen tempid=_n
	keep if inrange(tempid,16,20) | inrange(tempid,10,12) 
	replace type = "Large retailer gap, small firms, all" if tempid==10
	replace type = "Large retailer gap, small firms, major" if tempid==11
	replace type = "Large retailer gap, small firms, $15" if tempid==12
	
	gsort -tempid
	drop tempid
	append using `dw_estimates'
	gen tempid=_n	
	*gsort -tempid
	expand 2, gen(aux)
	gen ci=lb if aux==0
	replace ci=ub if aux==1
	
	bysort aux: gen id=_n
	gen ygraphval=.
	 
	replace ygraphval=1 if id==1  
	replace ygraphval=2 if id==2   
	replace ygraphval=3 if id==3   
	replace ygraphval=4 if id==4  
	replace ygraphval=5 if id==5   
	replace ygraphval=6 if id==6  
	replace ygraphval=7 if id==7  
	replace ygraphval=8 if id==8  
	replace ygraphval=9 if id==9   
	replace ygraphval=10 if id==10   
	replace ygraphval=11 if id==11 
	replace ygraphval=12 if id==12   
	replace ygraphval=13 if id==13  
	replace ygraphval=14 if id==14   
	replace ygraphval=15 if id==15  
	replace ygraphval=16 if id==16  
	replace ygraphval=17 if id==17   
	replace ygraphval=18 if id==18  
	replace ygraphval=19 if id==19   
	replace ygraphval=20 if id==20  
	replace ygraphval=21 if id==21   
	replace ygraphval=22 if id==22  
	replace ygraphval=23 if id==23 
	replace ygraphval=24 if id==24 
	replace ygraphval=25 if id==25 	
	replace ygraphval=26 if id==26 	
	replace ygraphval=27 if id==27 	
	replace ygraphval=28 if id==28 	
	replace ygraphval=29 if id==29 	

	label define ygraphvallabels    ///	
	29 "Same ind as large retailer (All)" ///
	28 "Connected ind (All)" ///
	27 "Connected estab (All)" ///
	26 "High emp share of large retailer (All)" ///
	25 "Same ind, high emp share (All)" ///
	24 "Connected ind, high emp share (All)" ///
	23 "Connected estab, high emp share (All)" ///
	22 "Same ind as large retailer (Major)" ///
	21 "Connected ind (Major)" ///
	20 "Connected estab (Major)" ///
	19 "High emp share of large retailer (Major)" ///
	18 "Same ind, high emp share (Major)" ///
	17 "Connected ind, high emp share (Major)" ///
	16 "Connected estab, high emp share (Major)" ///
	15 "Same ind as large retailer ($15)" ///
	14 "Connected ind ($15)" ///
	13 "Connected estab ($15)" ///
	12 "High emp share of large retailer ($15)" ///
	11 "Same ind, high emp share ($15)" ///
	10 "Connected ind, high emp share ($15)" ///
	9 "Connected estab, high emp share ($15)" ///
	8 "Small firms (All)" ///
	7 "Small firms (Major)" ///
	6 "Small firms ($15)" ///
	5 "" ///
	4 "All (Staiger, Spetz, & Phibbs, 2010)" ///
	3 "Within 15 mi (Staiger, Spetz, & Phibbs, 2010)" ///
	2 "Wage p25 (Bassier, 2024)"  ///
	1 "Wage p50 (Bassier, 2024))"  ///

	label values ygraphval ygraphvallabels

	twoway scatter ygraphval estimate if id>5, mc("$dnwblue") m(s) ///
		|| scatter ygraphval estimate if id<=5, mc("$dnwbrown") m(s) ///
		|| scatter ygraphval ci if ygraphval==1, c(l) lc("$dnwbrown") m(i) lp(solid)  ///
		|| scatter ygraphval ci if ygraphval==2, c(l) lc("$dnwbrown") m(i)lp(solid)  ///
		|| scatter ygraphval ci if ygraphval==3, c(l) lc("$dnwbrown") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==4, c(l) lc("$dnwbrown") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==5, c(l) lc("$dnwbrown") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==6, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==7, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==8, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==9, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==10, c(l) lc("$dnwblue") m(i) lp(solid)  ///
		|| scatter ygraphval ci if ygraphval==11, c(l) lc("$dnwblue") m(i) lp(solid)  ///
		|| scatter ygraphval ci if ygraphval==12, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==13, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==14, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==15, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==16, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==17, c(l) lc("$dnwblue") m(i) lp(solid) ///				
		|| scatter ygraphval ci if ygraphval==18, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==19, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==20, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==21, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==22, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==23, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==24, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==25, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==26, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==27, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==28, c(l) lc("$dnwblue") m(i) lp(solid) ///
		|| scatter ygraphval ci if ygraphval==29, c(l) lc("$dnwblue") m(i) lp(solid) ///
		yline(1/4 6/29,lc(gs12) lwidth(thin) lp(dot)) ///
		xline(0, lp(solid) lc("$dnwblue") lw(vthin)) ///
		graphregion(color(white)) ///
		ylab(1/4 6/29, labsize(small) valuelabel angle(0) nogrid tlength(0)) ytitle("") ///
		xlab(-.1(.2)1.5, labsize(small)) xtitle("Estimated Cross-Employer Wage Elasticities", size(small)) legend(off) ///
		scheme(plotplain)
		
	gr export "$figures_tables/fig9_cw_elasticities.pdf", replace
	
	*------------------------------------------------------------------------------------------------------------%	
	* Figure 10: Cross-wage elasticities compared to BHM prediction
	*------------------------------------------------------------------------------------------------------------%	
	insheet using "$figures_tables/estimates/cross_wage_elasticities.csv", clear
	twoway (scatter estimate bhm_cwe, mcolor("$dnwcrimson")) ///
	|| (line bhm_cwe bhm_cwe, lcolor("$dnwblue")),  legend(off) ///
	graphregion(color(white)) yla(,nogrid) xla(,nogrid) ///
	text(.05 .25 "Market = Same CZ X Industry as VMW Firm (3D NAICS)", size(small)) ///
	text(.10 .03 "Same CZ X" "Connected Ind" "(3D NAICS)" "& Establishments", size(small)) ///
	text(.3 .35 "45-degree line") ///
	ytitle("Estimated CWE") xtitle("BHM-predicted CWE") 
	gr export "$figures_tables/fig10_cw_elasticities_bhm_comparison.pdf", replace
	
	*------------------------------------------------------------------------------------------------------------%	
	* Figure F1: Cross-wage elasticities compared to Bassier prediction
	*------------------------------------------------------------------------------------------------------------%	
	insheet using "$figures_tables/estimates/cross_wage_elasticities.csv", clear
	twoway (scatter estimate bassier_cwe, mcolor("$dnwcrimson")) ///
	|| (line bassier_cwe bassier_cwe, lcolor("$dnwblue")),  legend(off) ///
	graphregion(color(white)) yla(,nogrid) xla(,nogrid) ///
	text(.1 .6 "Market = Same CZ X Industry as VMW Firm (3D NAICS)", size(small)) ///
	text(.1 .2 "Same CZ X" "Connected Ind" "(3D NAICS)" "& Establishments", size(small)) ///
	text(.37 .45 "45-degree line") ///
	ytitle("Estimated CWE") xtitle("Bassier-predicted CWE") 
	gr export "$figures_tables/appendix/figf5_cw_elasticities_bassier_comparison.pdf", replace
		
		